package com.broada.apm.es.indices.service;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;

import com.broada.apm.es.bean.ClusterInfo;
import com.broada.apm.indicator.api.common.ApmDataIndicatorException;

public interface IndexService {

	public void buildIndex(String index) throws ApmDataIndicatorException;

	public void buildIndex(String index, String alias, Settings indexSettings) throws ApmDataIndicatorException;

	/**
	 * 创建索引
	 * 
	 * @param index
	 * @param type
	 * @param alias
	 * @param mapping
	 * @throws ApmDataIndicatorException
	 */
	public void buildIndex(String index, String type, String alias, XContentBuilder mapping)
			throws ApmDataIndicatorException;

	/**
	 * 创建索引
	 * 
	 * @param index
	 * @param indexSettings
	 *          Settings indexSettings =
	 *          ImmutableSettings.settingsBuilder().put("number_of_shards", 1)
	 *          .put("number_of_replicas", 1).build();
	 * @param type
	 * @param alias
	 * @param mapping
	 * @throws ApmDataIndicatorException
	 */
	public void buildIndex(String index,String type,String alias, Settings indexSettings, XContentBuilder mapping)
			throws ApmDataIndicatorException;

	/**
	 * 索引判断
	 * 
	 * @param index
	 * @return
	 */
	public boolean existsIndex(String index);

	/**
	 * 删除索引
	 * 
	 * @param indices
	 * @return
	 */
	public boolean deleteIndex(String... indices);

	/**
	 * 查询索引并返回
	 * 
	 * @param indices
	 * @return
	 * @throws ApmDataIndicatorException
	 */
	public String[] searchIndex(String... indices) throws ApmDataIndicatorException;

	/**
	 * 查询es信息
	 * 
	 * @return
	 * @throws ApmDataIndicatorException
	 */
	public ClusterInfo queryNodeStats() throws ApmDataIndicatorException;
}
